#include<stdio.h>
#include<string.h>


struct guangyibiao{
	char temp;
	int top;
};

int main()
{
	struct guangyibiao gyb[50];
	char str[101];
	int len = 0,i,shen = 0,want,g = 0;
	scanf("%s%d",str,&want);
	
	len = strlen(str);
	
	for(i=0;i<len;i++){
		if(str[i]=='('||str[i]=='['||str[i]=='{'){
			shen++;
		}
		else{
			if(str[i]==')'||str[i]==']'||str[i]=='}'){
				shen--;
			}
			else{
				gyb[g].temp = str[i];
				gyb[g].top = shen;
				g++;
			}
		}
	}
	for(i=0;i<g;i++){
		if(gyb[i].top == want){
			printf("%c ",gyb[i].temp);
		}
	}
	return 0;
}
